package com.example.leetcode.prcatice;

/** 给定单链表的头节点 head ，请反转链表，并返回反转后的链表的头节点。 */
public class OfferII24 {

    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null){
            return head;
        }
        ListNode listNode = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return listNode;
    }
}
